//放一些应用层通用函数以及临时测试函数

#include "common.h"
UART_HandleTypeDef huart8={0}; //UART句柄
void _putchar(char character) {
    uart8_send(&character,1);
}

void uart8_init(void)
{
    huart8.Instance=GPCOM8;					            //GPCOM8
	huart8.Init.BaudRate=1000000;				        //波特率
	huart8.Init.PinRxd=HAL_PIN_P0;                      //接收脚
	huart8.Init.PinTxd=HAL_PIN_P1;		                //发送脚
	HAL_UART_Init(&huart8);	

}

void uart8_send(u8* buf, u16 len)
{
    HAL_UART_Transmit(&huart8,buf,len,HAL_WAIT_FOREVER);
}






//实现pow()函数
double mypow(double num, double n)
{
     double value = 1;
     int i = 1;
     if (n == 0)
     {
         value = 1;
     }
     else
     {
         while (i++ <= n)
         {
             value *= num;
         }
     }
     return value;
 }
int result(int x, int y)
{
    int num = 1;
    for (int i = 1; i <= y; i++) {
        num *= x;
    }
    return num;
}
